using Game;

namespace SCIENEW {
    public static class CastingUtils {
        /// <summary>
        /// 获取某材料溶解后得到的熔融金属体积
        /// </summary>
        /// <param name="value"></param>
        /// <param name="material"></param>
        /// <returns></returns>
        public static float GetIronItemVolume(int value) {
            int content = Terrain.ExtractContents(value);
            //特例
            if (content == IronIngotBlock.Index) {
                return 2f;
            }
            if (content == RodBlock.Index) {
                return 1f;
            }
            if (content == IronBlock.Index) {
                return 18f;
            }

            //通解
            if (content == BaseItemBlock.Index) {
                ItemBlock item = ItemsBlockManager.GetItem(value);
                if (item is IMaterialBlock materialBlock && materialBlock.GetMaterial() is Materials.Iron) {
                    if (item is PlateItem { isSmall: false })
                        return 2f;
                    if (item is PlateItem { isSmall: true })
                        return 2 / 36f;
                    if (item is RodItem) return 1f;
                    if (item is MetalLineItem) return 0.25f;
                    if (item is PowderItem) return 2f;
                    if (item is OrePowderItem) return 2f;
                    if (item is ScrapIronItem) return 2f;
                    if (item is SteelGearItem) return 2f;
                    if (item is SteelWheelItem) return 2f;
                    if (item is UIronSheetItem) return 2f;
                }
            }
            else if (content == BaseNormalBlock.Index) {
                NormalBlock normalBlock = NormalBlockManager.GetNormalBlock(value);
                if (normalBlock is IMaterialBlock materialBlock && materialBlock.GetMaterial() is Materials.Iron) {
                    if (normalBlock is MetalNBlock) return 18f;
                }
            }

            return -1f;
        }

        public static float GetSteelItemVolume(int value) {
            int content = Terrain.ExtractContents(value);

            //通解
            if (content == BaseItemBlock.Index) {
                ItemBlock item = ItemsBlockManager.GetItem(value);
                if (item is IMaterialBlock materialBlock && materialBlock.GetMaterial() is Materials.Steel) {
                    if (item is PlateItem { isSmall: false })
                        return 2f;
                    if (item is PlateItem { isSmall: true })
                        return 2 / 36f;
                    if (item is RodItem) return 1f;
                    if (item is MetalLineItem) return 0.25f;
                    if (item is PowderItem) return 2f;
                    if (item is OrePowderItem) return 2f;
                    if (item is SteelGearItem) return 2f;
                    if (item is SteelWheelItem) return 2f;
                    if (item is MetalIngotItem) return 2f;
                }
            }
            else if (content == BaseNormalBlock.Index) {
                NormalBlock normalBlock = NormalBlockManager.GetNormalBlock(value);
                if (normalBlock is IMaterialBlock materialBlock && materialBlock.GetMaterial() is Materials.Steel) {
                    if (normalBlock is MetalNBlock) return 18f;
                }
            }

            return -1f;
        }
    }
}